package com.ycy.dubbo.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ycy.dubbo.entity.QueryTaskInstsDto;
import com.ycy.dubbo.entity.YcyResponse;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@RestController()
public class ProviderController {

  @PostMapping("/time")
  public YcyResponse getTime(@RequestBody Map<String, Object> map) {
    System.out.println(map);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String format = simpleDateFormat.format(new Date());
    return new YcyResponse(200, format);
  }

  @RequestMapping(value = "/search", method = RequestMethod.POST)
  public YcyResponse getTime(@RequestBody QueryTaskInstsDto queryTaskInstsDto) {
    try {
      System.out.println(new ObjectMapper().writeValueAsString(queryTaskInstsDto));
    } catch (JsonProcessingException e) {
      e.printStackTrace();
    }
    return new YcyResponse(200, "success");
  }

}
